package com.itheima02.day02;

/**
 * @author 刘全
 * @date 2021/7/16
 */
public class AnimalsTest {
    public static void main(String[] args) {
        useAnimals(new Cat());
        useAnimals(new Dog());
    }
    public static void useAnimals(Animals a){
        a.eat();
        if(a instanceof Cat){
            Cat c = (Cat)a;
            c.work();
        }else if(a instanceof Dog){
            Dog d = (Dog) a;
            d.watchHome();
        }
    }
}
